﻿using System;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;

namespace YJKSparseDistance
{
	[Transaction(TransactionMode.Manual)]
	internal class TestCmd_TestStairs : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			UIApplication application = commandData.Application;
			Application application2 = application.Application;
			UIDocument activeUIDocument = application.ActiveUIDocument;
			Document document = activeUIDocument.Document;
			Reference reference = activeUIDocument.Selection.PickObject((Autodesk.Revit.UI.Selection.ObjectType)1);
			Stairs stairs = document.GetElement(reference.ElementId) as Stairs;
			Transaction transaction = new Transaction(document, "test");
			transaction.Start();
			foreach (ElementId elementId in stairs.GetStairsRuns())
			{
				StairsRun stairsRun = document.GetElement(elementId) as StairsRun;
				foreach (Curve curve in stairsRun.GetFootprintBoundary())
				{
					document.Create.NewDetailCurve(activeUIDocument.ActiveView, curve);
				}
				foreach (Curve curve2 in stairsRun.GetStairsPath())
				{
					document.Create.NewDetailCurve(activeUIDocument.ActiveView, curve2);
				}
			}
			transaction.Commit();
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
